#ifndef EXPRESSION_H
#define EXPRESSION_H

#include <map>
#include <memory>
#include <vector>
#include "Common\stdafx.h"
#include "ExecuteRunTimeType.h"

namespace CExpression
{
	struct InternalStruct;

	class CEXPRESSIONUTIL_API Expression
	{
		friend class VariableNode;
	public:
		Expression();
		Expression(const ExpressionString &exp);
		//Expression(const Expression &exp);
		//Expression& operator=(const Expression &exp);
		~Expression();
		void Compile(const ExpressionString &str);
		void Eval();
		ExecuteRunTimeType ResultType();
		double DoubleResult();
		bool BoolResult();
		std::vector<const ExpressionString*>* VariableSymbols();
		void SetVariableValue(const ExpressionString &name,bool val);
		void SetVariableValue(const ExpressionString &name,double val);
		bool ErrorOccured();
		ExpressionString ErrorMsg();
	private:
		void RemoveVariableValue(std::map< ExpressionString,std::shared_ptr<VariableNode> >::iterator nodeIter);
		InternalStruct *expData;
	};
}

#endif